package com.shop.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.query.Query;

import com.shop.entity.Comment;
import com.shop.entity.Product;
import com.shop.util.HibernateUtil;

public class CommentDaoImpl {
	
	
	//	查询所有的评论
		 public List<Comment> getAllComment() {
			 Session session = null;
			  session = HibernateUtil.openSession();
		        String hql = "from Comment";
		        Query query = session.createQuery(hql);
		        return query.list();
		    }
		 
	//增加评论
			public Comment addComment(Comment comment) {
				 Session session = null;
				  session = HibernateUtil.openSession();
				  Transaction tx =session.beginTransaction();
			        session.save(comment);
			        tx.commit();
			        session.close();
			        return comment;
			    }
}
